<?php
include_once '../meihe/common.php';
if ($islogin == 1) {
} else exit("<script language='javascript'>window.location.href='./login.php';</script>");
?>
<?php
if (isset($_GET['kw'])) {
	$sql = " url='{$_GET['kw']}' or upzid='{$_GET['kw']}'";
	$numrows = $DB->count("SELECT count(*) from meihe_report WHERE{$sql}");
	$con = '包含 ' . $_GET['kw'] . ' 的共有 <b>' . $numrows . '</b> 条记录';
	$link = '&kw=' . $_GET['kw'];
} else {
	$numrows = $DB->count("SELECT count(*) from meihe_report WHERE `scfl`='1' or `scfl`='2'");
	$sql = "`scfl`='1' or `scfl`='2'";
	$con = '平台共有 <b>' . $numrows . '</b> 条记录';
}
?>
<form name="form1" id="form1">
	<div style="white-space:nowrap;overflow-x: auto;">
		<table class="layui-table layuiadmin-page-table">
			<thead>
				<tr>
					<th>
						<div class="custom-control custom-checkbox"><input name="chkAll1" type="checkbox" id="chkAll1" onclick="selectAll(this);" value="checkbox" class="custom-control-input"><label class="custom-control-label" for="chkAll1"></label></div>ID
					</th>
					<th>生成网址</th>
					<th>生成IP</th>
					<th>生成方式</th>
					<th>锁定用户</th>
					<th>时间</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
				<?php
				$pagesize = isset($_GET['num']) ? intval($_GET['num']) : 30;
				$pages = ceil($numrows / $pagesize);
				$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
				$offset = $pagesize * ($page - 1);
				$rs = $DB->query("SELECT * FROM meihe_report WHERE {$sql} order by id desc limit $offset,$pagesize");
				while ($res = $DB->fetch($rs)) {
					$content = explode('*', $res['content']);
					$content = mb_substr($content[0], 0, 16, 'utf-8');
					echo '<tr><td><div class="custom-control custom-checkbox"><input type="checkbox" name="checkbox[]" id="workorder' . $res['id'] . '" value="' . $res['id'] . '" class="custom-control-input"><label class="custom-control-label" for="workorder' . $res['id'] . '"></label></div>' . $res['id'] . '</td><td><a href="' . htmlspecialchars($res['url']) . '" rel="noreferrer" target="_blank">' . htmlspecialchars($res['url']) . '</a></td><td><a href="mailto:' . htmlspecialchars($res['email']) . '">' . htmlspecialchars($res['ip']) . '</td><td>' . $res['reason'] . '</td><td><span class="layui-btn layui-btn-xs btn-default" onclick="sso(' . $res['upzid'] . ')">查看</span></td><td>' . $res['date'] . '</td><td><a href="./hhfhxt.php?act=scjl&my=del&id=' . $res['id'] . '" class="btn btn-xs btn-danger" onclick="return confirm(\'你确实要删除此记录吗？\');">删除</a></td></tr>';
				}
				?>
			</tbody>
		</table>
		<div class="form-group mb-3">
			<input type="hidden" name="content" />
			<label for="example-input-normal" style="font-weight: 500">操作：
				<select class="form-control" style="display: inline;width: auto;" name="aid">
					<option selected>批量操作</option>
					<option value="2">&gt;删除选中</option>
				</select>
				<button class="btn btn-sm btn-primary" type="button" onclick="change()">确定</button>
			</label>
		</div>
	</div>
</form>
<div class="text-center">
	<?php
	#分页
	$pageList = new Page($numrows, $pagesize, 1, $link ?? 0);
	echo $pageList->showPage();
	?>
</div>
<script>
	$("#blocktitle").html('<?php echo $con ?>');
</script>